import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/ywx_limit.dart';
import 'package:app/src/ui/app_ui.dart';

import '../../../../../../http/bean/worksdo/hardware_return_bean.dart';
import '../../../../../../http/bean/worksdo/material_requisition_bean.dart';
import '../../../../../../manager/ywx_manager.dart';

///公用列表内容
class ContentList2 {
  static Widget ywxItem(
      BuildContext context, YwxItem? item, HardwareReturnListBean data) {
    if (item?.ReviewType == ReviewType.TicketCenter) {
      //原片请购
      return _TicketCenter(context, item, data);
    }
    return _TicketCenter(context, item, data);
  }

  //last true 不带‘/’ fals 带‘/’ 即：是否为最后一个字符
  static Widget _text(String name, String? value, {bool last = false}) {
    var str = name + ":$value";
    List<InlineSpan>? children = null;
    if (!last) {
      children = [
        TextSpan(text: '/', style: AppStyle.textStyleWithEntryGrey()),
      ];
    }
    return Text.rich(TextSpan(
        style: AppStyle.textStyleWithEntry(), text: str, children: children));
    return Text(
      str,
      style: AppStyle.textStyleWithEntry(),
    );
  }

  //自动换行
  static Widget _wrap(List<Widget> children) {
    return Padding(
        padding: EdgeInsets.symmetric(vertical: 8),
        child: Wrap(
          alignment: WrapAlignment.start,
          children: children,
        ));
  }

  //工单中心
  static Widget _TicketCenter(BuildContext context, YwxItem? item,
      HardwareReturnListBean materialInfo) {
    // return AppUi.getEmptyView();
    //   if (materialInfo.PurDemandList == null ||
    //       materialInfo.PurDemandList!.length <= 0) {
    //     return AppUi.getEmptyView();
    //   }
    //   // var data = materialInfo.PurDemandList![0];
    var data = materialInfo;
    //申请人
    Widget UserPersonName = _text(
        AppStrings.of(context).UserPersonName, data.PersonName,
        last: false);
    //申请日期
    Widget AddDate =
        _text(AppStrings.of(context).AddDate5, data.getAddDate(), last: true);
    return _wrap([UserPersonName, AddDate]);
  }
}
